using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using MySoft.Data;
using System.Data;
using ShareMarking.Entity;

namespace ShareMarking.Service
{
    public class sfdc_HospitalService : BaseDao<sfdc_Hospital>
    {
        #region "单例"
        private static sfdc_HospitalService service;
        public static sfdc_HospitalService Instance
        {
            get
            {
                if (service == null)
                {
                    service = new sfdc_HospitalService();
                }
                return service;
            }
        }
        #endregion


        #region 分页方法
        public DataTable Get_sfdc_Hospital_PageSelect(int pageNo, int pageSize,
                     string sort, out int totalCount, String Code__c, String Name__c, String Region__c, String Area__c, String MSR_StaffID__c,String Active__c)
        {
            WhereClip whereClip = new WhereClip("");

            //like
            if (whereClip.ToString().Length > 0)
            {
                //whereClip = WhereClip.Bracket(whereClip);//新版框架这句已经可以不要 this.Code__c, this.Name__c, this.Region__c, this.Area__c, this.MSR_StaffID__c,this.Active__c
            }
            if (!Code__c.IsNullOrEmpty())
            {
                whereClip = whereClip && sfdc_Hospital._.Code__c.Contains(Code__c);
            }
            if (!Name__c.IsNullOrEmpty())
            {
                whereClip = whereClip && sfdc_Hospital._.Name__c.Contains(Name__c);
            }
            if (!Region__c.IsNullOrEmpty())
            {
                whereClip = whereClip && sfdc_Hospital._.Region__c.Contains(Region__c);
            }
            if (!Area__c.IsNullOrEmpty())
            {
                whereClip = whereClip && sfdc_Hospital._.Area__c.Contains(Area__c);
            }
            if (!MSR_StaffID__c.IsNullOrEmpty())
            {
                whereClip = whereClip && sfdc_Hospital._.MSR_StaffID__c.Contains(MSR_StaffID__c);
            }
            if (!Active__c.IsNullOrEmpty())
            {
                if (Active__c == "true")
                {
                    whereClip = whereClip && sfdc_Hospital._.Active__c == 1;
                }
                else
                {
                    whereClip = whereClip && sfdc_Hospital._.Active__c == 0;
                }
            } 
            return Get_Entity_byPage_ToTable(pageNo, pageSize, whereClip, new OrderByClip(sort), out totalCount);


        }
        #endregion
    }

}

